package com.zhoushihao.class0807;

import java.util.Scanner;

public class Conform {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] str = new String[n];
        int flag = 0;
        int[] arr = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
        char[] ch = {'1','0','X','9','8','7','6','5','4','3','2'};
        for (int i = 0; i < n; i++) {
            str[i] = sc.next();
        }
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < str[i].length()-1; j++) {
                sum+=(str[i].charAt(j)-'0')*arr[j];
            }
            if(ch[sum%11] != str[i].charAt(str[i].length()-1)){
                System.out.println(str[i]);
                flag = 1;
            }
        }
        if(flag == 0) System.out.println("All passed");
    }
}
